home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 4
/
CDPD_IV.bin
/
e
/
mailinglists
/
amigae.0993sept.archive
/
000048_crash!prg.oxfor…d.ac.uk!m88jrh_Tue, 21 Sep 93 03:06:57 PST.msg
< prev
next >
Wrap
Internet Message Format
|
1994-05-26
|
6KB
Received: by bkhouse.cts.com (V1.16/Amiga)
id AA00000; Tue, 21 Sep 93 03:06:57 PST
Received: from sun2.nsfnet-relay.ac.uk by crash.cts.com with smtp
(Smail3.1.28.1 #18) id m0of2mx-0000NmC; Tue, 21 Sep 93 01:09 PDT
Received: from ecs.oxford.ac.uk (ecs.ecs) by prg.oxford.ac.uk id AA00945;
Tue, 21 Sep 93 09:08:45 +0100
Received: from ecs.ox.ac.uk (booth8.ecs) by ecs.oxford.ac.uk (4.1/ecs.1)
id AA08915; Tue, 21 Sep 93 09:10:29 BST
Received: by ecs.ox.ac.uk (4.1/ecs2.0) id AA01140; Tue, 21 Sep 93 09:09:41 BST
Via: uk.ac.oxford.prg; Tue, 21 Sep 1993 09:09:10 +0100
Date: Tue, 21 Sep 93 09:09:41 BST
Message-Id: <9309210809.AA01140@booth8.ecs.ox.ac.uk>
From: m88jrh@ecs.oxford.ac.uk
To: amigae@bkhouse.cts.com
Subject: A little E program
Dear All,
I've written a little program which someone else on this planet may find
useful. It's not very pretty but (I think) it works. Basically, it's for
people who have a version of TeX, like me, which doesn't decide what format
file to use from the command name it is invoked with (like the Unix version
does). For example, if you make a hard link to 'virtex' called 'latex' the
'lplain' format file will be used. Frustrated I set about making my TeX
do the same.
The program can be run from Workbench or the CLI (and it does different
things...). If run from the Workbench by itself it will invoke an interactive
session of TeX, LaTeX or any other kind of TeX you have by looking at the
name of the Workbench file. The command names TeX and LaTeX get translated
to format files 'plain' and 'lplain' respectively, any other name is taken to
be the format name.
If run with arguments from the CLI or Workbench, it will investigate each
file's icon (if it exists) for a 'DOTEXFMT' tooltype. This can be 'LATEX',
'TEX', or a format file name (like 'sliplain' or 'plain'). Otherwise it
looks through the first 20 lines to find a line which begins '\documentstyle'
or a comment '% latex' or '% tex'. These decide the format used. Failing
all this normal TeX is run (the 'plain' format).
I use this program in conjunction with ToolManager (2.1) to have only one
icon on the dock which does LaTeX or TeX according to the file. You can also
use it as the default tool for a TeX/LaTeX file.
Notice the use of the ReadArgs template 'FILE/M' to get standard arguments
(like C's argv stuff) for the CLI, and the SystemTagList function to spawn
asynchronous tasks. Also, I've used StringF which Wouter omitted from the
2.1b documentation!
Let me know if you tidy it up or fix it!
----
MODULE 'workbench/startup', 'workbench/workbench',
'icon', 'dos/dostags', 'dos/dos'
CONST NUMARGS=1024
DEF y=11
PROC main()
DEF i, wb:PTR TO wbstartup, args:PTR TO wbarg, olddir,
templ, rdargs=NIL, arglist[NUMARGS]:LIST
iconbase:=OpenLibrary('icon.library', 33)
IF wb:=wbmessage
IF iconbase=NIL
CleanUp(10)
ENDIF
args:=wb.arglist
IF wb.numargs<>1
args++
FOR i:=2 TO wb.numargs
IF args[].lock
olddir:=CurrentDir(args[].lock)
dofile(args[].name++)
CurrentDir(olddir)
ELSE
dofile(args[].name++)
ENDIF
ENDFOR
ELSE
interact(args[].name)
ENDIF
ELSE
IF iconbase=NIL
WriteF('Can''t open icon.library\n')
CleanUp(10)
ENDIF
templ:='FILE/M'
rdargs:=ReadArgs(templ,arglist,NIL)
IF rdargs
IF arglist AND (arglist:=arglist[])
WHILE arglist[]
dofile(arglist[]++)
ENDWHILE
ENDIF
FreeArgs(rdargs)
ENDIF
ENDIF
IF iconbase THEN CloseLibrary(iconbase)
ENDPROC
PROC dofile(file)
DEF handle=NIL, dobj:PTR TO diskobject, fmt=NIL,
sysline[256]:STRING, con=NIL, tool, i=0
handle:=Open(file, OLDFILE)
IF handle
IF dobj:=GetDiskObject(file)
IF tool:=FindToolType(dobj.tooltypes, 'DOTEXFMT')
LowerStr(tool)
IF StrCmp(tool, 'tex', ALL)
fmt:='plain'
ELSEIF StrCmp(tool, 'latex', ALL)
fmt:='lplain'
ELSEIF tool[]
fmt:=tool
ENDIF
ENDIF
ENDIF
IF fmt=NIL
WHILE (i++<20) AND (ReadStr(handle, sysline)<>-1)
IF StrCmp(sysline, '\\documentstyle', STRLEN)
fmt:='lplain'
ELSE
LowerStr(sysline)
IF StrCmp(sysline, '% latex', ALL)
fmt:='lplain'
ELSEIF StrCmp(sysline, '% tex', ALL)
fmt:='plain'
ENDIF
ENDIF
ENDWHILE
IF fmt=NIL
fmt:='plain'
ENDIF
ENDIF
Close(handle)
StringF(sysline, 'con:0/\d/640/94/DoTeX - \s/CLOSE/WAIT', y, file)
IF con:=Open(sysline, NEWFILE)
StringF(sysline, 'tex:bin/virtex &\s \s', fmt, file)
SystemTagList(sysline, [SYS_INPUT, NIL, SYS_OUTPUT, con,
SYS_ASYNCH, TRUE, NIL])
y:=y+11
IF y>106 THEN y:=11
ENDIF
IF dobj THEN FreeDiskObject(dobj)
ELSEIF wbmessage=NIL
WriteF('File "\s" does not exist\n', file)
ENDIF
ENDPROC
PROC interact(file)
DEF name[128]:STRING, sysline[256]:STRING, fmt, handle, pos, found
pos:=InStr(file, ':', 0)
IF pos=-1
pos:=0
ELSE
INC pos
ENDIF
WHILE (found:=InStr(file, '/', pos))<>-1
pos:=found+1
ENDWHILE
MidStr(name, file, pos, ALL)
StringF(sysline, 'CON:0/11/640/94/DoTeX -- \s running/CLOSE/WAIT', name)
IF handle:=Open(sysline, NEWFILE)
LowerStr(name)
IF StrCmp(name, 'latex', ALL)
fmt:='lplain'
ELSEIF StrCmp(name, 'tex', ALL)
fmt:='plain'
ELSE
fmt:=name
ENDIF
StringF(sysline, 'tex:bin/virtex &\s', fmt)
SystemTagList(sysline, [SYS_INPUT, handle, SYS_OUTPUT, handle,
SYS_ASYNCH, FALSE, NIL])
Close(handle)
ENDIF
ENDPROC
-----
_____ _
/ / | / /
/ /__/ /__/ Jason R. Hulance
/ /\ / / <m88jrh@uk.ac.oxford.ecs>
|_/ . / \ . / / .